<docs>
  ## 编辑个人基本信息
</docs>
<template>
  <div class="wrap">

    <co-form :model="data" :rules="rules" ref="form" label="工作经历">
      <co-input prop="dwmc" label="单位名称"
        v-model="data.dwmc" placeholder="请输入单位名称"></co-input>
      <!-- <co-input prop="jzkssj" label="就职开始时间" type="tel" @focus="selectDate('single')"
        v-model="data.jzkssj" placeholder="请输入就职开始时间"></co-input> -->
      <data-picker1 prop="jzkssj" label="就职开始时间"
        v-model="data.jzkssj"></data-picker1>
      <!-- <co-input prop="jzjzsj" label="就职截止时间" type="tel"
        v-model="data.jzjzsj" placeholder="请输入就职截止时间"></co-input> -->
      <data-picker1 prop="jzjzsj" label="就职截止时间"
        v-model="data.jzjzsj"></data-picker1>
      <!-- <data-picker prop="jzkssj" label="就职开始时间"
        v-model="data.jzkssj"></data-picker> -->
      <co-level-picker label="工作地点" prop="dwdd" v-model="data.dwdd"
        :name="gzdd_xs"
        table-name="cdg_regioncode"></co-level-picker>
      <co-input prop="jygw" label="就业岗位"
        v-model="data.jygw" placeholder="请输入就业岗位"></co-input>
      <co-input prop="xc" label="薪酬"
        v-model="data.xc" placeholder="请输入薪酬"></co-input>
      <co-input prop="gzsm" label="工作职责及取得成绩及取得成绩"
        v-model="data.gzsm" placeholder="请输入工作职责及取得成绩及取得成绩"></co-input>
    </co-form>
    <div class="btn-wrap">
      <button class="weui-btn weui-btn_primary" @click.prevent="save" type="button">保存</button>
      <button class="weui-btn weui-btn_default" @click="backBase" type="button">返回</button>
    </div>

  </div>
</template>
<script>
import $ from '@/common/js/axios';
import { validator } from 'common/js/valid';
import coForm from 'base/form/form';
import coInput from 'base/form/input';
import coSelect from 'base/form/select';
import coLevelPicker from 'base/form/levelPicker';
import dataPicker1 from 'base/form/dataPicker1';


export default {
  name: 'editWork',
  components: { coForm, coInput, coSelect, coLevelPicker, dataPicker1 },
  data() {
    return {
      show: false,
      data: {
        grqzid: '',
        gzjlid: '',
        jzjzsj: '', // 就职截止时间
        jzkssj: '', // 就职开始时间
        dwmc: '', // 单位名称
        dwdd: '', // 工作地点
        jygw: '', // 岗位
        gzsm: '', // 工作职责及取得成绩及取得成绩
        xc: '', // 薪资
        ywcz: '' // 业务操作，（1：新增，2：修改，0：删除）
      },
      rules: {
        jzjzsj: validator('11,"full","就职截止时间",false'), // 就职截止时间
        jzkssj: validator('48,full,"就职开始时间",false'), // 就职开始时间
        dwmc: validator('168,"full","单位名称",false'), // 单位名称
        dwdd: validator('32,"full","工作地点",false'), // 工作地点
        jygw: validator('168,"full","岗位",false'), // 岗位
        gzsm: validator('168,"full","工作职责及取得成绩及取得成绩",false'), // 描述
        xc: validator('9,"number","薪酬",false') // 薪资
      },
      gzdd_xs: '',
    };
  },
  methods: {
    save() {
      this.$refs.form.validate(() => {
        this.POST_save();
      });
    },

    openPicker() {
      this.$refs.picker.open();
    },
    /* 保存基本信息修改 */
    POST_save() {
      this.$loading = true;
      this.$http.post('/url/post/grgl_gzjlBc', this.data).then(res => {
        const resData = res.returnData;
        this.$alert(resData.message, () => {
          const code = +resData.executeResult;
          if (code) {
            this.backBase();
          }
        });
      }).finally(() => {
        this.$loading = false;
      });
    },
    /* 返回基础信息 */
    backBase() {
      this.$router.go(-1);
    }
  },
  created() {
    var gzjl = this.$route.query;
    Object.keys(this.data).forEach(item => {
      this.data[item] = gzjl[item];
    });
    this.data.dwdd = gzjl.gzdd;
    this.data.jygw = gzjl.gzgw;
    // 行政区划显示
    this.gzdd_xs = gzjl.gzdd_xs;
  }
};
</script>
<style scoped lang="scss">
@import '~common/scss/var.scss';
.wrap {
  .btn-wrap {
    display: flex;
    .weui-btn {
      margin: $margin-base auto;
      flex: 0 1 47%;
    }
  }
}
</style>
